package com.ddwl.wallet.dao;

import com.ddwl.wallet.dao.mapper.UserSubsidyMapper;
import com.ddwl.wallet.dao.model.UserSubsidy;
import com.ddwl.common.dao.TkDao;
import org.springframework.stereotype.Repository;

import java.math.BigDecimal;

/**
 * 用户购物津贴表(UserSubsidy)数据处理
 *
 * @author zach
 * @since 2020-07-29 17:38:03
 */
@Repository
public class UserSubsidyDao  extends TkDao<UserSubsidyMapper, UserSubsidy> {

    public UserSubsidy getCouponByCouponId(String userId){
        UserSubsidy subsidy = new UserSubsidy();
        subsidy.setUserId(userId);
        UserSubsidy userSubsidy = selectOne(subsidy);
        if(userSubsidy==null){
            userSubsidy = new UserSubsidy();
            userSubsidy.setUserId(userId);
            userSubsidy.setAmount(BigDecimal.ZERO);
            insert(userSubsidy);
        }
        return userSubsidy;
    }

}